import jwt
import datetime
from django.conf import settings


def token_create(payload, timeout=1):
    headers = {'typ': 'JWT', 'alg': 'HS256'}
    payload = {'exp': datetime.datetime.utcnow() + datetime.timedelta(minutes=timeout)}
    token = jwt.encode(payload, settings.SECRET_KEY, algorithm='HS256')
    return token
